var express = require('express');
var router = express.Router();
const {User,Laboratory,Equipment,bookinfo} = require('../../models')
const {success,failure} = require('../../util/requestResult')
const {NotFoundError,BadRequestError,UnauthorizedError,AlreadyExistsError,SequelizeValidateError} = require('../../util/errors')
console.log(User);
console.log(Laboratory);
console.log(Equipment);
console.log(bookinfo);

router.get('/',async function(req, res, next) {
    try {
        const laboratorys = await Laboratory.findAll({
            include:[
                {
                model:Equipment,
                as:'Equipments',
                attributes:['id','equipmentName','openTime','closeTime','isApplyBook']
                },
            ],
        })
        success(res,'查询实验室成功',laboratorys)
    } catch (error) {
        failure(res,error)
    }
  
});

module.exports = router;
